package phase04.module02.code.consumerinterceptors;

import org.apache.kafka.clients.consumer.ConsumerInterceptor;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.OffsetAndMetadata;
import org.apache.kafka.common.TopicPartition;

import java.util.Map;

/**
 * @author Alex Zhang
 */
public class ConsumerInterceptorExample2 implements ConsumerInterceptor<String, String> {

    @Override
    public ConsumerRecords<String, String> onConsume(ConsumerRecords<String, String> records) {
        System.out.println("Two started");
        return records;
    }

    @Override
    public void onCommit(Map<TopicPartition, OffsetAndMetadata> offsets) {
        // 提交偏移量时
    }

    @Override
    public void close() {
        // 关闭用到资源
    }

    @Override
    public void configure(Map<String, ?> configs) {
        // 获取、设置参数
    }
}
